import 'package:boss/ui/page/storeEvaluate/page/content_page.dart';
import 'package:boss/ui/page/storeEvaluate/provider/provider.dart';
import 'package:boss/ui/widget/center_title_app_bar.dart';
import 'package:flutter/material.dart';
import 'package:hi_common/hi_common.dart';
import 'package:provider/provider.dart';
import 'package:router/annotation.dart';

@RouterConfig(StoreEvaluate.pageName)
class StoreEvaluate extends StatefulWidget {
  static const pageName = '/storeEvaluatePage';

  @Autowired()
  final String unionOrderId;

  @Autowired()
  final String beginTime;

  @Autowired()
  final String endTime;

  const StoreEvaluate({Key key, this.unionOrderId, this.beginTime, this.endTime}) : super(key: key);

  @override
  MyStoreEvaluate createState() => MyStoreEvaluate('门店评价');
}

class MyStoreEvaluate extends BaseState<StoreEvaluate> {
  MyStoreEvaluate(String pageName) : super(pageName);

  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        ChangeNotifierProvider(
          create: (context) => StoreCommentProvider(
            searchText: widget.unionOrderId ?? '',
            beginTime: widget.beginTime ?? (DateTime.now().toString().substring(0, 10)),
            endTime: widget.endTime ?? (DateTime.now().toString().substring(0, 10)),
          ),
        ),
      ],
      child: Scaffold(
        resizeToAvoidBottomInset: false,
        appBar: CenterTitleAppBar(
          title: '门店评价',
        ),
        body: ContentPage(unionOrderId: widget?.unionOrderId ?? null),
      ),
    );
  }
}
